<?php

namespace app\api\controller;

use think\Db;
use think\Request;

class Gift extends Common
{
    public function lists(Request $request = null)
    {
     //print_r($request->param());die;
        $types = $request->param('types') ?: 1;
        $page = $request->param('page') ?: 1;
        $isnew = $request->param('isnew') ?? 0;//是否新版礼物 0否 1是
        //echo $isnew;die;
        $where='';
        if($isnew){
            $where="isnew=1";
        }else{
            $where="isnew=0";
        }
        $data = Db::name('gift')
            ->field('types', true)
            ->where([
                'types' => $types,
                'channel'=>1,
                'channel_sex'=>[
                    'in',
                    $this->member['sex'] == '女'?[0,1]:[0,2]
                ]
            ])
            ->where($where)
            ->order('price asc, id desc')->page($page, 10)->select();
        //echo Db::name('gift')->getLastSql();die;
        
        return $this->pass($data);
    }
}
